﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Caliburn.Micro;
using Microsoft.Phone.Shell;
using Phone.Framework.Net;
using System.Threading;
using Phone.Framework.Threads;
using System.Collections.Generic;

namespace Phone.Framework.CaliburnExtensions.Results
{
    public class LoadingResult : IResult
    {
        private string _text;
        public LoadingResult(string text)
        {
            _text = text;
        }

        public void Execute(ActionExecutionContext context)
        {
            if (SystemTray.ProgressIndicator == null)
            {
                SystemTray.ProgressIndicator = new ProgressIndicator() { IsIndeterminate = true};
            }
            SystemTray.ProgressIndicator.IsVisible = true;
            SystemTray.ProgressIndicator.Text = _text;
            Completed(this, new ResultCompletionEventArgs());
        }

        public static LoadingResult Default()
        {
            return new LoadingResult("加载中");
        }

        public event EventHandler<ResultCompletionEventArgs> Completed;
    }

    public class LoadedResult : IResult
    {

        public void Execute(ActionExecutionContext context)
        {
            if (SystemTray.ProgressIndicator != null)
            {
                SystemTray.ProgressIndicator.IsVisible = false;
            }
            Completed(this, new ResultCompletionEventArgs());
        }

        public static LoadedResult Default()
        {
            return new LoadedResult();
        }

        public event EventHandler<ResultCompletionEventArgs> Completed;
    }
}